package vip.xiaonuo.modular.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.business.entity.BiUserIndexType.DefaultIndexVo;
import vip.xiaonuo.modular.business.param.BiUserIndexType.EditParam;
import vip.xiaonuo.modular.business.param.BiUserIndexType.QueryParam;
import vip.xiaonuo.modular.business.param.BiUserIndexType.StyleParam;
import vip.xiaonuo.modular.business.service.IndexTypeManageService;
import vip.xiaonuo.modular.entitys.UserIndexTree;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @Author cy
 * @Date 2022/8/2 18:47
 * @Version 1.0
 */

@Api(tags = "用户指标配置")
@RestController
public class IndexTypeManageController {

    @Resource
    private IndexTypeManageService indexTypeManageService;

    @ApiOperation("指标管理-用户指标树查询")
    @PostMapping("/business/biIndexType/tree")
    @BusinessLog(title = "用户指标树查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData tree(@RequestBody QueryParam param){
        UserIndexTree tree = indexTypeManageService.indexTypeTree(param);
        return new SuccessResponseData(tree);
    }

    @ApiOperation("指标管理-用户指标树编辑")
    @PostMapping("/business/biIndexType/treeEdit")
    @BusinessLog(title = "用户指标编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData treeEdit(@RequestBody EditParam param){
        indexTypeManageService.edit(param);
        return new SuccessResponseData();
    }

    @ApiOperation("配置中心-默认指标/图层展示")
    @PostMapping("/business/biIndexType/defaultIndexList")
    @BusinessLog(title = "默认指标/图层展示", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData defaultIndexList(){
        List<DefaultIndexVo> list =  indexTypeManageService.defaultList();
        return new SuccessResponseData(list);
    }

    @ApiOperation("配置中心-默认指标/图层用户编辑")
    @PostMapping("/business/biIndexType/editDefaultIndex")
    @BusinessLog(title = "默认指标/图层用户编辑", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData editDefaultIndex(@RequestBody List<DefaultIndexVo> editList){
        indexTypeManageService.editList(editList);
        return new SuccessResponseData();
    }

    @ApiOperation("用户指标样式配置")
    @PostMapping("/business/biIndexType/userStyle")
    @BusinessLog(title = "用户指标样式配置", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData userStyle(@RequestBody StyleParam param){
        indexTypeManageService.userStyle(param);
        return new SuccessResponseData();
    }


    @ApiOperation("自定义指标编辑")
    @PostMapping("/business/biIndexType/customAdd")
    @BusinessLog(title = "自定义指标编辑", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData customAdd(@RequestBody DefaultIndexVo vo){
        int i = indexTypeManageService.customAdd(vo);
        return new SuccessResponseData(i);
    }
    @PostMapping("/business/biIndexType/customDelete")
    public ResponseData customDelete(@RequestBody DefaultIndexVo vo){
        indexTypeManageService.customDelete(vo);
        return new SuccessResponseData();
    }
    @PostMapping("/business/biIndexType/customList")
    public ResponseData customList() {
        List<DefaultIndexVo> defaultIndexVos = indexTypeManageService.customList();
        return new SuccessResponseData(defaultIndexVos);
    }

    @PostMapping("/business/biIndexType/customTree")
    public ResponseData customTree(@RequestBody DefaultIndexVo vo) {
        List<DefaultIndexVo> defaultIndexVos = indexTypeManageService.customTree(vo);
        return new SuccessResponseData(defaultIndexVos);
    }
}
